package com.huawei;

/**
 * Created by Z-hong on 2024/7/23.
 */

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.function.BiConsumer;


public class HJ67 {

    public static Map<Integer, Integer> map = new HashMap<>();
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int in[] = new int[4];
        for (int i = 0; i < 4; i++) {
            in[i] = sc.nextInt();
        }
        map.put(in[0], 1);
        set(in[1], 2);
        set(in[2], 3);
        set(in[3], 4);
        boolean res = map.containsKey(24) && map.get(24) == 4;
        System.out.println(res);
    }

    public static void set(int number, int i) {
        Map<Integer, Integer> temp = new HashMap<>();
        temp.putAll(map);
        //加
        temp.forEach((k, v)->map.put(k + number, i));
        //减
        temp.forEach((k, v)->map.put(k - number, i));
        temp.forEach((k, v)->map.put(number - k, i));
        //乘
        temp.forEach((k, v)->map.put(k * number, i));
        //除
        temp.forEach(new BiConsumer<Integer, Integer>() {
            @Override
            public void accept(Integer k, Integer v) {
                if (k==0||number==0) return;

                if (k % number == 0) {
                    map.put(k / number, i);
                }
                if (number % k == 0) {
                    map.put(number / k, i);
                }
            }
        });
    }
}
